home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_10.lha / 7_10 / p_waitvec.c < prev    next >
Text File  |  1993-08-08  |  921b  |  42 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <process.h>
  6. include <debug.h>    /* DELETE */
  7. / pause until one of the objects listed
  8. / in the vector becomes available.
  9. nt process::wait(process_object **wv)
  10.  
  11.    if (debug) /*DELETE*/ cerr << "process" << this << "::wait(vec)\n";
  12.    if (mustrecurse())
  13. return wait(wv);
  14.  
  15.    else
  16. {
  17. t_desiredtime = 0;
  18.  
  19. for (;;)
  20.     {
  21.     // look for object not pending
  22.     for (int i = 0; wv[i] != 0; i++)
  23.     {
  24.     if (!wv[i]->pending())
  25.         {
  26.         // tell everyone to forget us
  27.         for (int j = 0; wv[j] != 0; j++)
  28.         wv[j]->forget(this);
  29.         if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::wait(vec) <- " << i << "\n";
  30.         return i;
  31.         }
  32.  
  33.     wv[i]->remember(this);
  34.     }
  35.  
  36.     if ((i == 0) && (wv[0] == (process_object*)this))
  37.     error("trying to wait for self");
  38.     pause();
  39.     }
  40. }
  41.  
  42.